home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl5
- #
- # connect-isdn.cgi
- #
- # Copyright 1988-1996 Silicon Graphics, Inc.
- # All rights reserved.
- #
- # This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- # the contents of this file may not be disclosed to third parties, copied or
- # duplicated in any form, in whole or in part, without the prior written
- # permission of Silicon Graphics, Inc.
- #
- # RESTRICTED RIGHTS LEGEND:
- # Use, duplication or disclosure by the Government is subject to restrictions
- # as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- # and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- # successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- # rights reserved under the Copyright Laws of the United States.
- #
- # $Id: connect-isdn.cgi,v 1.26 1997/04/17 23:43:38 shotes Exp $
-
- require "/usr/OnRamp/lib/OnRamp.pm";
-
- if (!$ARGV[0]) { printf("Location: %s%c%c","/tasks/Tasks.connect-start.cgi",10,10); }
-
- $myname = "connect-isdn.cgi";
- $temp = "task.tmp";
- $action= "connect-isdn.cgi?loop";
-
- $it = "<td align=right><font size=4>";
- $ni = "</font></td>";
- $bo = "<td><font size=5><i>";
- $nb = "</i></font></td>";
-
- @find_vals = ('switchtype','phone','spid1','spid2');
-
- &get_fields;
-
- if ($ARGV[0] eq 'loop') { %vals = %fld; }
- else { &readValues; }
-
- if ($ARGV[0] eq loop) {
- &errorCheck;
- &writeFile;
-
- $go = "/tasks/connect-end.cgi?i";
- #printf("Location: %s%c%c",$go,10,10);
- print "Content-type: text/html\n\n";
- print "<HTML><HEAD>";
- print "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=$go\">";
- print "</HEAD><BODY></BODY></HTML>";
- exit 0;
- }
-
-
- &generic;
-
- sub readValues {
- open(IN,"< $temp");
- while(<IN>) {
- @items = split(/=/);
- foreach $arg (@find_vals) {
- if ($arg eq $items[0]) {
- if ($items[1] ne "\n") {
- $vals{$arg} = $items[1];
- chop $vals{$arg};
- }
- }
- }
- }
- close(IN);
- }
-
- sub errorCheck {
- &error("Phone number required.") if !$fld{'phone'};
- &error("Invalid phone number.") if &check_phone($fld{'phone'});
- if ($fld{'switchtype'} eq 'DMS100' || $fld{'switchtype'} eq 'NI1') {
- &error("Two SPID numbers required for switch type $fld{'switchtype'}.")
- if (!$fld{'spid1'} || !$fld{'spid2'});
- &error("Invalid SPID number: $fld{'spid1'}.") if $fld{'spid1'} =~ /[^0-9]/;
- &error("Invalid SPID number: $fld{'spid2'}.") if $fld{'spid2'} =~ /[^0-9]/;
- }
- }
-
- sub error {
- $error = $_[0];
- &generic;
- exit 0;
- }
-
- sub writeFile {
- $fld{'phone'} =~ s/\(//g;
- $fld{'phone'} =~ s/\)//g;
- $fld{'phone'} =~ s/\-//g;
- $fld{'phone'} =~ s/\,//g;
- $fld{'phone'} =~ s/ //g;
-
- undef %terms;
- open(IN,"< $temp");
- while(<IN>) {
- @items = split(/=/);
- chop $items[1];
- $terms{$items[0]} = $items[1];
- }
- close(IN);
- foreach $arg (@find_vals) {
- if ($fld{$arg} eq "NET3/DSS1") { $terms{$arg} = "NET3"; next; }
- $terms{$arg} = $fld{$arg};
- }
- open(OUT,"> $temp");
- foreach $arg (keys(%terms)) {
- print OUT "$arg=$terms{$arg}\n";
- }
- close(OUT);
- }
-
- sub generic {
- print "Content-type: text/html\n\n";
- print "<html><head><title>ISDN Configuration</title>\n";
- print "<script language=\"JavaScript\">\n<!--\n";
-
- # JavaScript
- print "function Next() {
- form = document.isdn;
- if (!testPhone(form)) return;
- if (!testSwitch(form)) return;
- setTimeout('form.submit()',0);
- return;
- }\n";
- print "function Previous() {
- setTimeout('window.location=\"connect-second.cgi?i\"',0);
- return;
- }\n";
- print "function testPhone(form) {
- Ctrl = form.phone;
- if (Ctrl.value == \"\") { errorBox (Ctrl, \"The phone number is required.\"); return (false); }
- error = testPhoneChars(Ctrl.value);
- if (error == 1) { errorBox (Ctrl, \"The phone number cannot contain spaces.\"); return (false); }
- if (error == 2) { errorBox (Ctrl, \"The phone number cannot contain \\nletters or punctuation.\"); return (false); }
- return (true);
- }\n";
- print "function testPhoneChars(word) {
- for(i = 0; i < word.length; i++) {
- c = word.charAt(i);
- if (c == ' ') return 1;
- if (c != \'(\' && c != \')\' && c != \'-\' && c != \',\') {
- num = parseInt(c);
- if(isNaN(num)) return 2;
- }
- } return 0;
- }\n";
- print "function testSwitch(form) {
- Ctrl = form.switchtype; selnum = Ctrl.selectedIndex;
- selected = Ctrl.options[selnum].text;
- if (selected == \"DMS100\" || selected == \"NI1\") {
- word1 = form.spid1.value; word2 = form.spid2.value;
- if(word1 == \"\" || word2 == \"\") {
- errorBox (Ctrl, \"Two SPID numbers are required for \\nswitch type \" + selected); return (false);
- }
- for(i=0; i < word1.length; i++) {
- if(isNaN(parseInt(word1.charAt(i)))) {
- errorBox (Ctrl, \"Invalid SPID number: \" + word1); return (false);
- }
- if(isNaN(parseInt(word2.charAt(i)))) {
- errorBox (Ctrl, \"Invalid SPID number: \" + word2); return (false);
- }
- }
- }
- return (true);
- }\n";
- print "function errorBox (Ctrl, ErrorMessage) {
- alert (ErrorMessage); Ctrl.focus(); return;
- }\n";
-
- print "//-->\n";
- print "</script></head>\n\n";
-
- print "<body bgcolor=\'c7ded4\' background=/tasks/connect-task.bg.gif>\n";
-
- if ($error) {
- print "<font size=4 color=ff0000><b>Error: </b>$error<br></font>";
- }
- print "<i>$message</i>";
-
- print "<table width=100%>",
- "<tr><th align=left><h1>ISDN Configuration</h1></th>\n",
- "<th align=right><a href=\"/newsplash.shtml\">",
- "<img height=55 width=57 border=0 src=/tasks/home.gif></a>\n",
- " <a href=\"/tasks/Tasks.shtml\">",
- "<img height=55 width=57 border=0 src=/tasks/back.gif></a>",
- "</tr></table>\n";
-
- printf("<form name=\"isdn\" action=\"%s\" method=post>\n", $action);
-
- print "<center><table width=620>";
-
- print "<tr>$bo Phone number of your service provider: $nb \n$it",
- &text("phone",$vals{'phone'},15),
- "$ni </tr>\n";
- print " <tr><td colspan=2>
- To connect to the Internet, the Gateway places a call over the ISDN
- line to a host at the service provider's site. The phone number is
- required to reach the host, just as a phone number is required for
- a standard voice call. (Your ISP supplies this phone number.) Do
- not include any punctuation symbols or spaces with the number.
- </td></tr><tr><td> </td></tr>\n\n";
-
- print "<tr>$bo Switch used by your service provider: $nb \n$it",
- &select("switchtype",$vals{'switchtype'},
- 'DMS100',
- 'NI1',
- '5ESS',
- 'NTT',
- 'NET3/DSS1',
- '1TR6',
- 'VN3',
- 'TPH'),
- "$ni </tr>\n";
- print " <tr><td colspan=2>
- Your ISDN configuration must be set to the type of switching equipment
- that your ISDN provider uses. This options menu contains a list of
- commonly used switch types from which to select. (Switch types, and
- the additional information that some switches require, are specified
- by your ISDN provider.)
- </td></tr><tr><td> </td></tr>\n\n";
-
- print "</table></center><center><table width=620>";
-
- print "<tr>$bo SPID numbers: $nb \n$it",
- &text("spid1",$vals{'spid1'},15), "$ni $it\n",
- &text("spid2",$vals{'spid2'},15),
- "$ni </tr>\n";
- print " <tr><td colspan=3>
- If your provider uses DMS100 or NI1 switches, SPID numbers are
- required. These numbers identify the available services on your
- ISDN line. (Your ISDN provider supplies SPID numbers.)
- </td></tr><tr><td> </td></tr>\n";
- print "</table></center>\n";
-
- print '<MAP NAME="js_map1">',
- ' <AREA SHAPE="rect" COORDS="0,0,59,52" HREF="javascript:Previous()"
- onMouseOver="window.status=\'\';return true">',
- '</MAP>';
- print "\n";
- print '<MAP NAME="js_map2">',
- ' <AREA SHAPE="rect" COORDS="0,0,59,52" HREF="javascript:Next()"
- onMouseOver="window.status=\'\';return true">',
- '</MAP>';
- print "\n";
- print '<IMG SRC="/tasks/rightarrow.gif" BORDER=0 USEMAP="#js_map2" align="right">';
- print "\n";
- print '<IMG SRC="/tasks/leftarrow.gif" BORDER=0 USEMAP="#js_map1" align="right">';
-
- print "\n</form></body></html>";
- }
-
-